import type { IDanmakuImage, IDanmakuOptions } from '@/compnents';
import { IDBAddMarkerParams, IDBEditMarkerParams, IDBFindMarkerData, IDBFindMarkerParams } from '@/db';
import { Point } from 'geojson';

export type IApiRes<T = any> = {
  data: T;
  code: number;
  message: string;
  success: boolean;
};

export type IApiDanmakuRecord = IDanmakuOptions & {
  lng: number;
  lat: number;
  zoom: number;
};

export type IApiQueryDanmakuParams = Partial<IApiDanmakuRecord> & { bbox?: number[] };

export type IApiQueryDanmakuResult = IApiRes<IApiDanmakuRecord[]>;

export type IApiQueryDanmakuConfigResult = IApiRes<IDanmakuImage[]>;

export type IApiInsertDanmakuParams = Omit<IApiDanmakuRecord, 'id' | 'time'>;

export type IApiInsertDanmakuResult = IApiRes;

export type IApiTDTSearchParams = { lng: number; lat: number; ver?: number };

export type IApiTDTSearchData = {
  formatted_address: string;
  location: {
    lon: number;
    lat: number;
  };
  addressComponent: {
    address: string;
    town: string;
    nation: string;
    city: string;
    county_code: string;
    poi_position: string;
    county: string;
    city_code: string;
    address_position: string;
    poi: string;
    province_code: string;
    town_code: string;
    province: string;
    road: string;
    road_distance: number;
    address_distance: number;
    poi_distance: number;
  };
};

export type IApiTDTSearchRes<T = any> = {
  result: T;
  msg: string;
  status: string;
};

export type IApiGeovisRegeoMoreParams = {
  points: { lng: number; lat: number }; //传入的经纬度，多个经纬度用“竖线符号”分割
  radius?: number; //查询范围
  pageSize?: number; //返回数据每页长度
  currentPage?: number; //返回数据第几页
  classify?: string; //Poi类型编码
};

export type IApiGeovisPageInfo<T = any> = {
  total: number;
  rows: T;
};

export type IApiGeovisRegeoMoreData = {
  id: string;
  name: string;
  lat: number;
  lng: number;
  address: string;
  code: string;
  province: string;
  city: string;
  county: string;
  geomtype: string;
  geometry: Point;
  similarity: number;
  distance: string;
  distanceCalculation: number;
  poiType: string;
  status: number;
  statusName: string;
  srcLng: number;
  srcLat: number;
  fullMath: boolean;
  geoId: string;
  poiId: string;
  hotWeight: string;
};

export type IApiGeovisRegeoMoreRes = {
  status: 200;
  data: IApiGeovisPageInfo<IApiGeovisRegeoMoreData>;
};

export type IApiAddMarkerParams = IDBAddMarkerParams;
export type IApiEditMarkerParams = IDBEditMarkerParams;
export type IApiFindMarkerParams = IDBFindMarkerParams;
export type IApiFindMarkerResult = IApiRes<IDBFindMarkerData>;
export type IApiFindAllMarkerResult = IApiRes<IDBFindMarkerData[]>;
